<script lang="ts" setup>
import { fetchApp } from '@/api'
import { set } from '@vueuse/core'

const emit = defineEmits(['update:modelValue'])
const loading = ref(false)
const state = reactive<any>({
  // 列表数据
  list: [],
})

// 获取列表
const getList = () => {
  set(loading, true)

  fetchApp().then((res: any) => {
    Array.isArray(res.rows) && (state.list = res?.rows.reverse())

    setTimeout(() => {
      set(loading, false)
    }, 80)
  })
}

getList()

const handleChange = (v: any) => {
  emit('update:modelValue', v)
}
</script>
<template>
  <a-select :style="{ width: '155px' }" @change="handleChange" placeholder="请选择应用" :default-value="1">
    <a-option v-for="item in state.list" :key="item.id" :value="item.id">{{ item.name }}</a-option>
  </a-select>
</template>
<style lang="scss"></style>
